package performanceTests.openGraph;
import java.util.Date;
import report.Report;
import vg.configuration.SimpleConfiguration;
import vg.core.VisualGraph;
import vg.logging.FileLog;
import vg.logging.SimpleLog;
import vg.logging.WindowMessage;
import vg.model.SQLite4JavaModel;
import vg.modules.opener.CommandOpener;
import vg.progress.SimpleProgressManager;
import junit.framework.Assert;
import junit.framework.TestCase;
/**
* This suite tests opening graph.
* @author tazolotu
*/
public class TestSuite1 extends TestCase{
public TestSuite1(String s) {
super(s);
// set all system services------------
try {
VisualGraph.setLog(new FileLog());
} catch (Throwable ex) {
ex.printStackTrace();
VisualGraph.setLog(new SimpleLog());
}
VisualGraph.setWindowMessage(new WindowMessage());
VisualGraph.setConfiguration(SimpleConfiguration.getInstance());
VisualGraph.setProgressManager(new SimpleProgressManager());
}
public void openGraph_pcg_attr1_graphml() {
try {
System.out.println("\n[TestSuite1.openGraph_pcg_attr1_graphml]");
SQLite4JavaModel model = new SQLite4JavaModel();
System.out.println("Warmup state: opening of 3 graphs");
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(int i = 0; i < 10; i++) {
long start = new Date().getTime();
int id = CommandOpener.openFile("../Visual Graph/example/pcg_attr1.graphml", model);
if(id < 0) {
model.quit();
Report.addRecord("TestSuite1", "pcg_attr1_graphml", "Error: Return value < 0", "sec");
Assert.assertTrue("Error: Return value < 0", false);
return;
}
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
model.quit();
Report.addRecord("TestSuite1", "pcg_attr1_graphml", Float.valueOf(best).toString(), "sec");
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("TestSuite1", "pcg_attr1_graphml", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
public void openGraph_big_gml() {
try {
System.out.println("\n[TestSuite1.openGraph_big_gml]");
SQLite4JavaModel model = new SQLite4JavaModel();
System.out.println("Warmup state: opening of 3 graphs");
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
CommandOpener.openFile("../Visual Graph/example/Attributes.graphml", model);
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(int i = 0; i < 10; i++) {
long start = new Date().getTime();
int id = CommandOpener.openFile("../Visual Graph/example/Big.gml", model);
if(id < 0) {
model.quit();
Report.addRecord("TestSuite1", "big_gml", "Error: Return value < 0", "sec");
Assert.assertTrue("Error: Return value < 0", false);
return;
}
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
model.quit();
Report.addRecord("TestSuite1", "big_gml", Float.valueOf(best).toString(), "sec");
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("TestSuite1", "big_gml", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
}